package com.kkd.kkdapp.activity;

import java.lang.ref.WeakReference;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

import com.google.gson.Gson;
import com.kkd.kkdapp.Environment;
import com.kkd.kkdapp.R;
import com.kkd.kkdapp.base.BaseActivity;
import com.kkd.kkdapp.http.entity.AccountInfoRes;
import com.kkd.kkdapp.http.entity.FinanceDto;
import com.kkd.kkdapp.http.entity.FinancialPlanningData;
import com.kkd.kkdapp.http.entity.FirstPoiTipsData;
import com.kkd.kkdapp.http.entity.Home;
import com.kkd.kkdapp.http.entity.HomeData;
import com.kkd.kkdapp.http.entity.MyDiscountCouponData;
import com.kkd.kkdapp.http.entity.MyDiscountCouponDataList;
import com.kkd.kkdapp.http.entity.ParticularsData;
import com.kkd.kkdapp.http.manager.HttpCallBack;
import com.kkd.kkdapp.http.manager.KkdHttpMagager;
import com.kkd.kkdapp.listener.OnSingleClickListener;
import com.kkd.kkdapp.utils.AppUtil;
import com.kkd.kkdapp.utils.AuthenticationUtils;
import com.kkd.kkdapp.utils.DialogUtils;
import com.kkd.kkdapp.utils.LogUtil;
import com.kkd.kkdapp.utils.PreferenceUtils;
import com.kkd.kkdapp.utils.SystemUtils;
import com.kkd.kkdapp.utils.Tools;
import com.kkd.kkdapp.view.KkdListHeader;
import com.kkd.kkdapp.view.ScrollerLayout;
import com.kkd.kkdapp.view.ScrollerLayout.OnPullListener;
import com.kkd.kkdapp.view.ScrollerLayout.ScrollStateProvider;
import com.kkd.kkdapp.view.EditText.FinanceEditText;
import com.kkd.kkdapp.view.EditText.FinanceEditText.onFinanceEditListener;
import com.kkd.kkdapp.view.xlistview.XListViewHeader;
import com.kkd.kkdapp.widget.adapters.AbstractWheelTextAdapter;

/**
 * 投标确认
 * 
 * @author mty rebuild by zhaochaung at 20160527
 */
public class TenderAffirmActivity extends BaseActivity {

	private static final int ACCOUNTINFO_CODE_ZERO = 1; // 账户余额code=0
	private static final int ACCOUNTINFO_CODE_ELSE = 2; // 账户余额code=其它
	private static final int JUMP_REGULAR_SUCCESS = 10000; // 定期投标价成功跳转请求码
	private static final int KKXF_REGULAR_SUCCESS = 20000; // 快快享福投标成功跳转请求码

	private Button next_bt; // 下一步
	private RelativeLayout affirm_title_img; // 返回
	private FinanceEditText invest_ed; // 投标金额
	private String bidId; // 标的ID
	private TextView balance_tv1;
	private TextView recharge; // 充值
	private String bidTitle; // 标的标题
	private TextView name_tv;
	private int bidPeriod; // 期限
	private TextView allotted;
	private Dialog mSinaDialog;
	private AccountInfoRes mAccountInfo;
	private double balance;
	private long amountMultiple; // 倍数
	private long lowestAmount; // 最小金额
	private String bidPeriodType; // 期限单位
	private TextView rise_tv;
	private String bidType;
	private RelativeLayout discount; // 优惠券选择
	private String discountName = "不使用优惠券";
	private List<MyDiscountCouponDataList> mDataList = new ArrayList<MyDiscountCouponDataList>();
	private RelativeLayout show_dis;
	private TextView discount_tv;
	private TextView discount_unused;
	private TextView display;
	private TextView display1;
	private TextView display2;
	private String Title; // 优惠券标题
	private int mAmount = 0; // 优惠券面值
	private int mLowestAmount; // 优惠券最低起投金额
	private String mCouponId = "";
	private TextView procedure_tv1; // 剩余金额
	private long bidFreeAmount; // 标剩余金额
	private long maxAmount;
	private TextView hint;
	private boolean updateFlag = false;
	private Dialog mDialog;
	private long bidAmount;
	private long totalLixi;
	private TextView predict_ed;
	private int mType = -1;
	private String bidInterest = "";
	private String url;
	DecimalFormat df = new DecimalFormat("0.00");
	DecimalFormat df1 = new DecimalFormat("###,###.00");
	DecimalFormat df2 = new DecimalFormat("###,##0");
	DecimalFormat df3 = new DecimalFormat("##.##");
	private double predict = 0;
	// private ImageView discount_img;
	private double dbidInterest = 0.0;
	private String earnings = "";
	private TextView rise_tv1;
	private int mId = -3;
	private double experiencePrincipal;
	private String bmouts;
	private Dialog nsfDialog; // 账户余额不足对话框
	private Dialog tenderDialog; // 投标等待Dialog
	private Dialog succeedDialog; // 投标成功结果Dialog
	private String businessType;
	private String loading = "正在投标,请稍候......";
	private String repayment;
	private String startInterest;
	TextView allotte_company; // 理财单位
	private int productType;
	private Dialog beDefeatedDialog;// 投标失败结果Dialog
	private String poiId;
	private boolean isRegular = true;
	private boolean REFRESHFLAG = false;
	private boolean firstCoupon = true;
	private boolean couponErr = false;
	private boolean tenderContinue = false;
	private int bidPeriodAdd;
	private String newMisTips; // 是否显示新手任务
	private String firstPoiTips1; // 是否完成首投
	private String firstPoiTips2; // 是否完成首投
	private TextView whole_bt; // 全投
	private Dialog happyCoinCompleteProgressDialog;
	private int isNewbie;
	private Dialog loadDialog;

	private Handler mHandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case ACCOUNTINFO_CODE_ZERO:
				if (loadDialog != null) {
					loadDialog.dismiss();
				}
				if (mAccountInfo.getWithholdAuth().getWithdrawStatus() == 1) {

					showSinaDialog();
				}
				balance_tv1.setText("" + bmouts);
				// ---------------------------
				if ("501".equals(bidType)) {
					experiencePrincipal = mAccountInfo.getExperiencePrincipal();
					String experiencePrincipal_format = df
							.format(experiencePrincipal);
					balance_tv1.setText("" + experiencePrincipal_format);
				}
				break;
			case ACCOUNTINFO_CODE_ELSE:
				if (loadDialog != null) {
					loadDialog.dismiss();
				}
				String desc = (String) msg.obj;
				showToast(desc);
				break;
			}
		};
	};
	private LinearLayout linear_can_tip;
	private TextView tv_can_tip_1;
	private TextView tv_can_tip_2;
	private TextView tv_can_tip_3;
	private View rel_tip;
	private TextView tv_tip;
	private ScrollerLayout mScrollView;
	private String bidPeriodWeb;
	private Dialog dialog_finishShoutou;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tender_affirm);
		Intent intent = getIntent();
		bidId = intent.getStringExtra("bidId");
		bidTitle = intent.getStringExtra("bidTitle");
		bidPeriod = intent.getIntExtra("bidPeriod", 0);
		bidPeriodWeb = intent.getStringExtra("bidPeriodWeb");
		amountMultiple = intent.getLongExtra("amountMultiple", 0);
		lowestAmount = intent.getLongExtra("lowestAmount", 0);
		bidPeriodType = intent.getStringExtra("bidPeriodType");
		bidType = intent.getStringExtra("bidType");
		bidInterest = intent.getStringExtra("bidInterest");
		bidFreeAmount = intent.getLongExtra("bidFreeAmount", 0);
		maxAmount = intent.getLongExtra("maxAmount", 0);
		bidAmount = intent.getLongExtra("bidAmount", 0);
		totalLixi = intent.getLongExtra("totalLixi", 0);
		businessType = intent.getStringExtra("businessType");
		productType = intent.getIntExtra("productType", 0);
		bidPeriodAdd = intent.getIntExtra("bidPeriodAdd", 0);
		isNewbie = intent.getIntExtra("isNewbie", -1);
		LogUtil.e("TAG", "" + bidPeriodAdd);
		initUI();

	}

	private void controlKeyboardLayout(final View root, final View scrollToView) {
		root.getViewTreeObserver().addOnGlobalLayoutListener(
				new OnGlobalLayoutListener() {
					@Override
					public void onGlobalLayout() {
						Rect rect = new Rect();
						// 获取root在窗体的可视区域
						root.getWindowVisibleDisplayFrame(rect);
						// 获取root在窗体的不可视区域高度(被其他View遮挡的区域高度)
						int rootInvisibleHeight = root.getRootView()
								.getHeight() - rect.bottom;
						// 若不可视区域高度大于100，则键盘显示
						if (rootInvisibleHeight > 100) {
							int[] location = new int[2];
							// 获取scrollToView在窗体的坐标
							scrollToView.getLocationInWindow(location);
							// 计算root滚动高度，使scrollToView在可见区域
							int srollHeight = (location[1] + scrollToView
									.getHeight()) - rect.bottom;
							root.scrollTo(0, srollHeight);
						} else {
							// 键盘隐藏
							root.scrollTo(0, 0);
						}
					}
				});
	}

	private KkdListHeader mHeaderView;
	private RelativeLayout mHeaderViewContent;
	private ScrollView nScrollView;
	private View rel_new_task;
	private TextView tv_tip_black;
	private TextView tv_tip_orange;
	private TextView tv_timespace_newtask;
	private RelativeLayout rel_cancelCoupon;

	/**
	 * 初始化组件
	 */
	public void initUI() {
		/*
		 * 此处以下为新手任务及首投相关
		 */
		rel_new_task = findViewById(R.id.rel_new_task);// 新手任务总布局
		tv_tip_black = (TextView) findViewById(R.id.tv_tip_black);// 提示前半段
		tv_tip_orange = (TextView) findViewById(R.id.tv_tip_orange);// 提示后半段
		tv_timespace_newtask = (TextView) findViewById(R.id.tv_timespace_newtask);// 新手任务剩余时间
		/*
		 * 此处以上为新手任务及首投相关
		 */
		nScrollView = (ScrollView) findViewById(R.id.childScroll);
		mScrollView = (ScrollerLayout) findViewById(R.id.mScrollView);
		mHeaderView = new KkdListHeader(this);
		mHeaderViewContent = (RelativeLayout) mHeaderView
				.findViewById(R.id.xlistview_header_content);
		mScrollView.addTopView(mHeaderView);
		mScrollView.setScrollStateProvider(new ScrollStateProvider() {

			@Override
			public boolean canPullUp() {
				return false;
			}

			@Override
			public boolean canPullDown() {
				if ("501".equals(bidType)) {
					return false;
				} else {
					int scrollY = nScrollView.getScrollY();
					if (scrollY == 0) {
						return true;
					}
				}
				return false;
			}
		});
		mScrollView.setOnPullListener(new OnPullListener() {

			@Override
			public void onPullUp(float pull) {

			}

			@Override
			public void onPullStateChange(byte state) {
				switch (state) {
				case ScrollerLayout.STATUS_IDLE:// 空闲状态
					mHeaderView.setVisibility(View.GONE);
					break;
				case ScrollerLayout.STATUS_PULL_DOWN:// 下拉：不满足hold条件
					mHeaderView.setVisibility(View.VISIBLE);
					mHeaderView.setState(XListViewHeader.STATE_NORMAL);
					break;
				case ScrollerLayout.STATUS_PULL_UP:// 上拉：不满足hold条件
					break;
				case ScrollerLayout.STATUS_UP_HOLD:// 上拉后等待状态
					break;
				case ScrollerLayout.STATUS_DOWN_HOLD:// 下拉后等待状态
					mHeaderView.setState(XListViewHeader.STATE_REFRESHING);
					if (AppUtil.isConnect(TenderAffirmActivity.this)) {
						REFRESHFLAG = true;
						if ("401".equals(bidType)) { // K计划
							requestInterface();
						} else { // 非K计划
							requestParticulars();
						}
						getAccountInfo();
						couponList();
					} else {
						AppUtil.makeToastForCustomer(TenderAffirmActivity.this,
								"网络异常");
						mScrollView.clearState();
					}
					break;
				case ScrollerLayout.STATUS_ANIMATING:// 回弹动画状态
					break;
				case ScrollerLayout.STATUS_PULL_DOWN_ENABLE:// 下拉：满足hold条件，松开将hold
					mHeaderView.setState(XListViewHeader.STATE_READY);
					break;
				case ScrollerLayout.STATUS_PULL_UP_ENABLE: // 上拉：满足hold条件，松开将hold
					break;
				default:
					break;
				}
			}

			@Override
			public void onPullDown(float pull) {

			}
		});

		next_bt = (Button) findViewById(R.id.next_bt);
		LinearLayout mRoot = (LinearLayout) this.findViewById(R.id.root);
		// controlKeyboardLayout(mRoot, next_bt);
		next_bt.setOnClickListener(mOnSingleClickListener);
		affirm_title_img = (RelativeLayout) findViewById(R.id.affirm_title_img);
		affirm_title_img.setOnClickListener(mOnSingleClickListener);

		recharge = (TextView) findViewById(R.id.recharge);
		recharge.setOnClickListener(mOnSingleClickListener);

		discount = (RelativeLayout) findViewById(R.id.discount);
		discount.setOnClickListener(mOnSingleClickListener);

		linear_can_tip = (LinearLayout) findViewById(R.id.linear_can_tip);
		tv_can_tip_1 = (TextView) findViewById(R.id.tv_can_tip_1);
		tv_can_tip_2 = (TextView) findViewById(R.id.tv_can_tip_2);
		tv_can_tip_3 = (TextView) findViewById(R.id.tv_can_tip_3);
		rel_tip = findViewById(R.id.rel_tip);
		tv_tip = (TextView) findViewById(R.id.tv_tip);
		whole_bt = (TextView) this.findViewById(R.id.whole_bt);
		whole_bt.setOnClickListener(mOnSingleClickListener);
		whole_bt.setClickable(false);
		if ("501".equals(bidType)) {
			isRegular = false;
			TextView lable_balance = (TextView) findViewById(R.id.lable_balance);
			lable_balance.setText("特权本金(元)：");
			recharge.setVisibility(View.GONE);
			discount.setVisibility(View.GONE);
			rel_tip.setVisibility(View.GONE);
			findViewById(R.id.line).setVisibility(View.GONE);
		}
		name_tv = (TextView) findViewById(R.id.name_tv);
		name_tv.setText(bidTitle);

		allotted = (TextView) findViewById(R.id.allotted);
		allotte_company = (TextView) findViewById(R.id.allotte_company);
		if (TextUtils.isEmpty(bidPeriodWeb)) {
			allotted.setText(bidPeriod + "");
			if ("天".equals(bidPeriodType)) {
				allotte_company.setText(bidPeriodType);
			} else if ("月".equals(bidPeriodType)) {
				allotte_company.setText("个" + bidPeriodType);
			}
		} else {
			allotted.setText(bidPeriodWeb + "");
		}

		rise_tv = (TextView) findViewById(R.id.rise_tv);
		rise_tv1 = (TextView) findViewById(R.id.rise_tv1);
		interestRate();
		procedure_tv1 = (TextView) findViewById(R.id.procedure_tv1);
		procedure_tv1.setText(""
				+ SystemUtils.numberWithDelimiter(bidFreeAmount / 100));

		hint = (TextView) findViewById(R.id.hint);
		if (maxAmount != 0) {
			hint.setText(df2.format(maxAmount / 100) + "元");
		} else {
			hint.setText("无");
		}

		if (!TextUtils.isEmpty(bidInterest)) {
			int index = bidInterest.indexOf("+");
			if (index == -1) {
				dbidInterest = Double.parseDouble(bidInterest);
			} else if (index != -1) {
				String[] bidInterestArr = bidInterest.split("\\+");
				String onebidInterest1 = bidInterestArr[0];
				String twobidInterest1 = bidInterestArr[1];

				double onebidInterest = Double.parseDouble(onebidInterest1);
				double twobidInterest = Double.parseDouble(twobidInterest1);

				dbidInterest = onebidInterest + twobidInterest;
			}
		}

		show_dis = (RelativeLayout) findViewById(R.id.show_dis);
		discount_tv = (TextView) findViewById(R.id.discount_tv);
		rel_cancelCoupon = (RelativeLayout) findViewById(R.id.rel_cancelCoupon);
		rel_cancelCoupon.setOnClickListener(mOnSingleClickListener);
		discount_unused = (TextView) findViewById(R.id.discount_unused);
		display = (TextView) findViewById(R.id.display);
		display1 = (TextView) findViewById(R.id.display1);
		display2 = (TextView) findViewById(R.id.display2);
		predict_ed = (TextView) findViewById(R.id.predict_ed);
		TextView taffirm_title_tv = (TextView) this
				.findViewById(R.id.taffirm_title_tv);
		// K计划 合同
		RelativeLayout financial_agreement_ll = (RelativeLayout) this
				.findViewById(R.id.financial_agreement_ll);
		// 借款合同
		TextView financial_agreement_tv2 = (TextView) this
				.findViewById(R.id.financial_agreement_tv2);
		// 债权转让协议
		TextView financial_agreement_tv3 = (TextView) this
				.findViewById(R.id.financial_agreement_tv3);
		// 债权转让协议
		TextView financial_agreement_tv4 = (TextView) this
				.findViewById(R.id.financial_agreement_tv4);
		financial_agreement_tv2.setOnClickListener(mOnSingleClickListener);
		financial_agreement_tv3.setOnClickListener(mOnSingleClickListener);
		financial_agreement_tv4.setOnClickListener(mOnSingleClickListener);
		if ("401".equals(bidType)) {
			taffirm_title_tv.setText("购买");
			next_bt.setText("购买");
			financial_agreement_ll.setVisibility(View.VISIBLE);
		} else {
			taffirm_title_tv.setText("投标");
			next_bt.setText("投标");
			financial_agreement_ll.setVisibility(View.INVISIBLE);
		}
		// discount_img = (ImageView) findViewById(R.id.discount_img);

		balance_tv1 = (TextView) findViewById(R.id.balance_tv1);
		invest_ed = (FinanceEditText) findViewById(R.id.invest_ed);
		invest_ed.setHint("需" + amountMultiple / 100 + "的整数倍");
		invest_ed.setDecimalDigits(0);
		invest_ed.setLimitMax(bidFreeAmount * 0.01);
		invest_ed.setOnEditorActionListener(new OnEditorActionListener() {

			@Override
			public boolean onEditorAction(TextView v, int actionId,
					KeyEvent event) {
				if (actionId == EditorInfo.IME_ACTION_DONE) {
					if (next_bt.isEnabled())
						tenderLogic();
				}
				return false;
			}
		});
		invest_ed.setFinanceEditListener(new onFinanceEditListener() {

			@Override
			public void onValueChanged(double toValue, double fromValue) {

				LogUtil.e("totalLixi", totalLixi + "");
				LogUtil.e("bidAmount", bidAmount + "");
				if (toValue > 0) {

					predict = toValue * 100 / bidAmount * totalLixi * 0.01;
					predict_ed.setText(df.format((int) (predict * 100) * 0.01));
					next_bt.setEnabled(true);

				} else {
					predict = 0;
					predict_ed.setText("0.00");
					next_bt.setEnabled(false);
				}

				if (updateFlag) {
					if ("不使用优惠券".equals(discountName)) {
						show_dis.setVisibility(View.GONE);
						display1.setText("");
						display2.setText("");
						interestRate();
						discount_tv.setText(mDataList.size() + "张可用");
						discount_tv.setTextColor(TenderAffirmActivity.this
								.getResources().getColor(R.color.white));
						discount_unused.setText("未使用");
						discount_unused.setVisibility(View.VISIBLE);
						linear_can_tip.setVisibility(View.GONE);
						discount_tv
								.setBackgroundResource(R.drawable.discountimg_bg_hui);
						// discount_unused.setTextColor(TenderAffirmActivity.this
						// .getResources().getColor(R.color.gray_999999));
						// rise_tv.setText(bidInterest + "%");
						// rise_tv.setTextColor(TenderAffirmActivity.this
						// .getResources().getColor(R.color.orange_ff7301));
						interestRate();
					} else {
						if (TextUtils.isEmpty(invest_ed.getText().toString())
								|| "".equals(invest_ed.getText().toString())) {
							discount_tv.setText(Title);
							show_dis.setVisibility(View.GONE);// 改过
							if (mType == 2) {
								interestRate();
								// rise_tv.setText(bidInterest + "%");
								// rise_tv.setTextColor(TenderAffirmActivity.this
								// .getResources().getColor(
								// R.color.orange_ff7301));
								discount_unused.setText("该优惠券最低"
										+ mLowestAmount / 100 + "元起投");
								discount_unused.setVisibility(View.VISIBLE);
								linear_can_tip.setVisibility(View.GONE);
								discount_tv
										.setBackgroundResource(R.drawable.discountimg_bg_hui);
								// discount_unused
								// .setTextColor(TenderAffirmActivity.this
								// .getResources().getColor(
								// R.color.green_a5a5a5));
							} else if (mType == 3) {
								interestRate();
								// rise_tv.setText(bidInterest + "%");
								// rise_tv.setTextColor(TenderAffirmActivity.this
								// .getResources().getColor(
								// R.color.orange_ff7301));
								discount_unused.setText("该优惠券最低"
										+ mLowestAmount / 100 + "元起投");
								discount_unused.setVisibility(View.VISIBLE);
								linear_can_tip.setVisibility(View.GONE);
								discount_tv
										.setBackgroundResource(R.drawable.discountimg_bg_hui);
								// discount_unused
								// .setTextColor(TenderAffirmActivity.this
								// .getResources().getColor(
								// R.color.green_a5a5a5));
							} else {
								interestRate();
								// rise_tv.setText(bidInterest + "%");
								// rise_tv.setTextColor(TenderAffirmActivity.this
								// .getResources().getColor(
								// R.color.orange_ff7301));
								discount_unused.setText("该优惠券最低"
										+ mLowestAmount / 100 + "元起投");
								discount_unused.setVisibility(View.VISIBLE);
								linear_can_tip.setVisibility(View.GONE);
								discount_tv
										.setBackgroundResource(R.drawable.discountimg_bg_hui);
								// discount_unused
								// .setTextColor(TenderAffirmActivity.this
								// .getResources().getColor(
								// R.color.green_a5a5a5));
							}
							display.setText("该优惠券最低起投金额为" + mLowestAmount / 100
									+ "元");
							display.setTextColor(TenderAffirmActivity.this
									.getResources().getColor(
											R.color.orange_ff6009));
						} else {
							if (mType == 2) {
								if (Integer.parseInt(invest_ed.getText()
										.toString()) >= mLowestAmount / 100) {
									show_dis.setVisibility(View.GONE);// 改过
									discount_tv.setText(Title);
									discount_tv
											.setTextColor(TenderAffirmActivity.this
													.getResources().getColor(
															R.color.white));
									discount_unused.setText("+" + mAmount
											* 0.01 + "%");
									discount_unused.setVisibility(View.GONE);
									linear_can_tip.setVisibility(View.VISIBLE);
									discount_tv
											.setBackgroundResource(R.drawable.discountimg_bg);
									tv_can_tip_1.setText("预计收益增加");
									tv_can_tip_2.setText(df.format((int) (((mAmount * 0.01)
											/ dbidInterest * Double.parseDouble(df
											.format((int) (predict * 100) * 0.01))) * 1000) / 10 * 0.01));
									tv_can_tip_3.setText("元");
									// discount_unused
									// .setTextColor(TenderAffirmActivity.this
									// .getResources()
									// .getColor(
									// R.color.orange_ff6009));
									LogUtil.e("dbidInterest1", ""
											+ dbidInterest);
									LogUtil.e("mAmount2", "" + mAmount * 0.01);
									LogUtil.e("predict2", "" + predict);
									double interest = (mAmount * 0.01)
											/ dbidInterest
											* Double.parseDouble(df
													.format((int) (predict * 100) * 0.01));
									LogUtil.e("interest1", "" + interest);
									display.setText("已加息+" + mAmount * 0.01
											+ "%，预计收益增加");
									display.setTextColor(TenderAffirmActivity.this
											.getResources().getColor(
													R.color.green_a5a5a5));
									earnings = df
											.format((int) (interest * 1000) / 10 * 0.01);
									display1.setText(earnings);
									display2.setText("元");
									if (!TextUtils.isEmpty(bidInterest)) {
										if (bidInterest.indexOf("+") == -1) {
											rise_tv.setText(Tools.intOrDouble(Double
													.parseDouble(bidInterest))
													+ "%");
											rise_tv1.setText("+"
													+ Tools.intOrDouble((double) (mAmount * 0.01))
													+ "%");
										} else {
											String[] bit = bidInterest
													.split("\\+");
											rise_tv.setText(Tools.intOrDouble(Double
													.parseDouble(bit[0]))
													+ "%");
											rise_tv1.setText("+"
													+ Tools.intOrDouble(Double
															.parseDouble(bit[1]))
													+ "%+"
													+ Tools.intOrDouble((double) (mAmount * 0.01))
													+ "%");
										}
									}
									// rise_tv.setText(bidInterest + "%");
									// rise_tv1.setText("+" + mAmount * 0.01 +
									// "%");
									if ("".equals(earnings)) {
										predict_ed.setText(df
												.format((int) (predict * 100) * 0.01));
									} else {
										predict_ed.setText(df.format(Double.parseDouble(df
												.format((int) (predict * 100) * 0.01))
												+ Double.parseDouble(earnings)));
									}
								} else {
									show_dis.setVisibility(View.GONE);// 改过
									display1.setText("");
									display2.setText("");
									discount_unused.setText("该优惠券最低"
											+ mLowestAmount / 100 + "元起投");
									discount_unused.setVisibility(View.VISIBLE);
									linear_can_tip.setVisibility(View.GONE);
									discount_tv
											.setBackgroundResource(R.drawable.discountimg_bg_hui);
									// discount_unused
									// .setTextColor(TenderAffirmActivity.this
									// .getResources()
									// .getColor(
									// R.color.green_a5a5a5));
									display.setText("该优惠券最低起投金额为"
											+ mLowestAmount / 100 + "元");
									display.setTextColor(TenderAffirmActivity.this
											.getResources().getColor(
													R.color.orange_ff6009));
									// rise_tv.setText(bidInterest + "%");
									interestRate();
								}

							} else if (mType == 3) {
								if (Integer.parseInt(invest_ed.getText()
										.toString()) >= mLowestAmount / 100) {
									show_dis.setVisibility(View.GONE);// 改过
									discount_tv.setText(Title);
									discount_unused.setText("¥"
											+ df3.format(mAmount * 0.01));
									discount_unused.setVisibility(View.GONE);
									linear_can_tip.setVisibility(View.VISIBLE);
									discount_tv
											.setBackgroundResource(R.drawable.discountimg_bg);
									tv_can_tip_1.setText("投标成功，返现");
									tv_can_tip_2.setText(df3
											.format(mAmount * 0.01));
									tv_can_tip_3.setText("元");
									discount_tv
											.setTextColor(TenderAffirmActivity.this
													.getResources().getColor(
															R.color.white));
									// discount_unused
									// .setTextColor(TenderAffirmActivity.this
									// .getResources()
									// .getColor(
									// R.color.orange_ff6009));
									display.setText("投标成功，返现");
									display.setTextColor(TenderAffirmActivity.this
											.getResources().getColor(
													R.color.green_a5a5a5));
									display1.setText(""
											+ df3.format(mAmount * 0.01));
									display2.setText("元");
									// rise_tv.setText(bidInterest + "%");
									interestRate();
								} else {
									// rise_tv.setText(bidInterest + "%");
									interestRate();
									show_dis.setVisibility(View.GONE);// 改过
									display1.setText("");
									display2.setText("");
									discount_unused.setText("该优惠券最低"
											+ mLowestAmount / 100 + "元起投");
									discount_unused.setVisibility(View.VISIBLE);
									linear_can_tip.setVisibility(View.GONE);
									discount_tv
											.setBackgroundResource(R.drawable.discountimg_bg_hui);
									// discount_unused
									// .setTextColor(TenderAffirmActivity.this
									// .getResources()
									// .getColor(
									// R.color.green_a5a5a5));
									display.setText("该优惠券最低起投金额为"
											+ mLowestAmount / 100 + "元");
									display.setTextColor(TenderAffirmActivity.this
											.getResources().getColor(
													R.color.orange_ff6009));
								}
							} else {
								if (Integer.parseInt(invest_ed.getText()
										.toString()) >= mLowestAmount / 100) {
									show_dis.setVisibility(View.GONE);// 改过
									discount_tv.setText(Title);
									discount_tv
											.setTextColor(TenderAffirmActivity.this
													.getResources().getColor(
															R.color.white));
									discount_unused.setText("-¥"
											+ df3.format(mAmount * 0.01));
									discount_unused.setVisibility(View.GONE);
									linear_can_tip.setVisibility(View.VISIBLE);
									discount_tv
											.setBackgroundResource(R.drawable.discountimg_bg);
									tv_can_tip_1.setText("实际支付");
									tv_can_tip_2.setText(df3.format(Integer
											.parseInt(invest_ed.getText()
													.toString())
											- mAmount * 0.01));
									tv_can_tip_3.setText("元");
									// discount_unused
									// .setTextColor(TenderAffirmActivity.this
									// .getResources()
									// .getColor(
									// R.color.orange_ff6009));
									display.setText("已优惠"
											+ df.format(mAmount * 0.01)
											+ "元，实际支付");
									display.setTextColor(TenderAffirmActivity.this
											.getResources().getColor(
													R.color.green_a5a5a5));
									display1.setText(df3.format(Integer
											.parseInt(invest_ed.getText()
													.toString())
											- mAmount * 0.01)
											+ "");
									display2.setText("元");
									interestRate();
									// rise_tv.setText(bidInterest + "%");
									// rise_tv.setTextColor(TenderAffirmActivity.this
									// .getResources().getColor(
									// R.color.orange_ff7301));
								} else {
									show_dis.setVisibility(View.GONE);// 改过
									display1.setText("");
									display2.setText("");
									discount_unused.setText("该优惠券最低"
											+ mLowestAmount / 100 + "元起投");
									discount_unused.setVisibility(View.VISIBLE);
									linear_can_tip.setVisibility(View.GONE);
									discount_tv
											.setBackgroundResource(R.drawable.discountimg_bg_hui);
									// discount_unused
									// .setTextColor(TenderAffirmActivity.this
									// .getResources()
									// .getColor(
									// R.color.green_a5a5a5));
									display.setText("该优惠券最低起投金额为"
											+ mLowestAmount / 100 + "元");
									display.setTextColor(TenderAffirmActivity.this
											.getResources().getColor(
													R.color.orange_ff6009));
									interestRate();
									// rise_tv.setText(bidInterest + "%");
									// rise_tv.setTextColor(TenderAffirmActivity.this
									// .getResources().getColor(
									// R.color.orange_ff7301));
								}
							}
						}
					}
				}

			}

			@Override
			public void onOutLimit() {
				// TODO Auto-generated method stub

			}

			@Override
			public void afterValueChanged(double toValue) {
				// TODO Auto-generated method stub

			}
		});
	}

	public void interestRate() {
		if (!TextUtils.isEmpty(bidInterest)) {
			if (bidInterest.indexOf("+") == -1) {
				rise_tv.setText(Tools.intOrDouble(Double
						.parseDouble(bidInterest)) + "%");
				rise_tv1.setText("");// 此行为修改取消使用加息券年化收益显示错误bug
			} else {
				String[] bit = bidInterest.split("\\+");
				rise_tv.setText(Tools.intOrDouble(Double.parseDouble(bit[0]))
						+ "%");
				rise_tv1.setText("+"
						+ Tools.intOrDouble(Double.parseDouble(bit[1])) + "%");
			}
		}
	}

	OnSingleClickListener mOnSingleClickListener = new OnSingleClickListener() {

		@Override
		public void onSingleClick(View v) {
			// TODO Auto-generated method stub
			onTenderClick(v);
		}
	};

	public void onTenderClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case R.id.next_bt: // 投标
			if (AppUtil.isConnect(this)) {
				tenderLogic();
			} else {
				showToast("网络错误，请稍后重试");
			}
			break;
		case R.id.affirm_title_img:
			SystemUtils.onEvent("Regular_BidPage_Back", 1);
			finish();
			break;
		case R.id.recharge: // 充值
			SystemUtils.onEvent("Regular_BidPage_Recharge", 1);
			if (PreferenceUtils.getInstance().getAutonym(this) == 1) {
				if (PreferenceUtils.getInstance().getBoundBankCard(this) == 1) {
					intent = new Intent(this, RechargeActivity.class);
					startActivity(intent);
				} else {
					intent = new Intent(this, ForTenderActivity.class);
					intent.putExtra("enterTypeFlag", 0);
					startActivity(intent);
				}
			} else {
				intent = new Intent(this, ForTenderActivity.class);
				intent.putExtra("enterTypeFlag", 4);
				startActivity(intent);
			}

			break;
		case R.id.discount: // 选择优惠券
			SystemUtils.onEvent("Regular_BidPage_Coupon", 1);
			if (mDataList != null) {
				if (mDataList.size() > 0) {
					intent = new Intent(this,
							TenderAffirmDiscountCouponActivity.class);
					intent.putExtra("mId", mId);
					intent.putExtra("mCouponId", mCouponId);
					intent.putExtra("businessType", businessType);
					intent.putExtra("bidId", bidId);
					startActivityForResult(intent, 50);
				}
			}
			break;
		case R.id.whole_bt: // 全投
			long long_yue = ((int) (balance / (amountMultiple / 100)))
					* (amountMultiple / 100);// 账户余额
			long long_shengyuedu = bidFreeAmount / 100;// 剩余金额
			long long_xiangou = maxAmount == 0 ? Long.MAX_VALUE
					: maxAmount / 100;// 限购额度
			long long_tiyanjin = 0;// 体验金余额
			long[] minAmount;
			if ("501".equals(bidType)) {// 体验金
				long_tiyanjin = ((int) (mAccountInfo.getExperiencePrincipal() / (amountMultiple / 100)))
						* (amountMultiple / 100);
				minAmount = new long[] { long_tiyanjin, long_shengyuedu,
						long_xiangou };// 依次为体验金余额，剩余额度，限购额度
			} else {
				minAmount = new long[] { long_yue, long_shengyuedu,
						long_xiangou };// 依次为账户余额，剩余额度，限购额度
			}
			Arrays.sort(minAmount);
			invest_ed.setText(minAmount[0] + "");
			invest_ed.setSelection(invest_ed.getText().toString().length());
			if ("501".equals(bidType)) {// 体验标
				if (minAmount[0] == long_tiyanjin) {// 最小值为账户余额
					AppUtil.makeToastForCustomer(this, "已自动填入可投的账户余额");
				} else if (minAmount[0] == long_xiangou) {// 最小值为限购额度
					AppUtil.makeToastForCustomer(this, "已自动填入可投的限购额度");
				} else if (minAmount[0] == long_shengyuedu) {// 最小值为剩余额度
					AppUtil.makeToastForCustomer(this, "已自动填入可投的标的剩余额度");
				}
			} else {
				if (minAmount[0] == long_yue) {// 最小值为账户余额
					AppUtil.makeToastForCustomer(this, "已自动填入可投的账户余额");
				} else if (minAmount[0] == long_xiangou) {// 最小值为限购额度
					AppUtil.makeToastForCustomer(this, "已自动填入可投的限购额度");
				} else if (minAmount[0] == long_shengyuedu) {// 最小值为剩余额度
					AppUtil.makeToastForCustomer(this, "已自动填入可投的标的剩余额度");
				}
			}
			break;
		case R.id.financial_agreement_tv2: // K计划服务协议
			LogUtil.e("TAG", "K计划服务协议");
			intent = new Intent(this, KKDWebActivity.class);
			intent.putExtra("url", Environment.getH5Url() + "kplanservice.html");
			startActivity(intent);
			break;
		case R.id.financial_agreement_tv3: // 借款合同
			LogUtil.e("TAG", "借款合同");
			intent = new Intent(this, KKDWebActivity.class);
			intent.putExtra("url", Environment.getH5Url() + "kplanagree.html");
			startActivity(intent);
			break;
		case R.id.financial_agreement_tv4: // 债权转让协议
			LogUtil.e("TAG", "债权转让协议");
			intent = new Intent(this, KKDWebActivity.class);
			intent.putExtra("url", Environment.getH5Url() + "kplandebt.html");
			startActivity(intent);
			break;
		case R.id.rel_cancelCoupon: // 取消优惠券选择
			discountName = "不使用优惠券";
			selectDiscount();
			break;

		}

	}

	/**
	 * tenderExperience:(快快享福投标逻辑). <br/>
	 * 
	 * @author askzhao
	 */
	private void tenderExperience() {
		String str = invest_ed.getText().toString();
		double invest_d = Double.parseDouble(str);
		double invest_i = Integer.parseInt(str);
		// 投标金额大于等于账户特权本金
		if (invest_d <= experiencePrincipal) {

			// 投标金额小于最低投资金额
			if (invest_i < lowestAmount / 100) {

				showToast("投资金额不得低于" + lowestAmount / 100 + "元");

			} else {// 投标金额大于最低投资金额

				if (amountMultiple == 0) { // 投资金额倍数
					// amountMultiple=
					// 0；
					showTenderToLoadDialog("投资金额 " + (int) (invest_d) + "元",
							loading);
					if ("401".equals(bidType)) { // K计划
						financialPlanningPurchase();
					} else { // 非K计划
						requesetPoi();
					}

				} else if (amountMultiple > 0) { // 投资金额倍数
					// amountMultiple>
					// 0；

					// 投标金额必须是amountMultiple的倍数
					if (invest_i % (amountMultiple / 100) == 0) {
						showTenderToLoadDialog(
								"投资金额 " + (int) (invest_d) + "元", loading);
						if ("401".equals(bidType)) { // K计划
							financialPlanningPurchase();
						} else { // 非K计划
							requesetPoi();
						}

					} else {

						showToast("投资金额需要是" + amountMultiple / 100 + "的整数倍");

					}

				}

			}

		} else { // 投标金额小于账户特权本金

			showToast("您的特权本金不足!");

		}

	}

	/**
	 * tenderNonExperience:(投资非快快享福逻辑). <br/>
	 * 
	 * @author askzhao
	 */
	private void tenderNonExperience() {
		String invest_str = invest_ed.getText().toString();
		double invest_d = Double.parseDouble(invest_str);
		double invest_i = Integer.parseInt(invest_str);
		if (mType == 1) { // 　使用抵现券

			// 投标金额 - 抵现券金额 <= 账户余额
			if (invest_d * 100 - mAmount <= balance * 100) {

				if (invest_i < lowestAmount / 100) {

					showToast("投资金额不得低于" + lowestAmount / 100 + "元");

				} else {

					if (amountMultiple == 0) {

						if (!(discount_unused.getText().toString()
								.startsWith("该优惠券最低") && discount_unused
								.getText().toString().endsWith("元起投"))) {
							showTenderToLoadDialog("投资金额" + (int) (invest_d)
									+ "元", loading);
							if ("401".equals(bidType)) { // K计划
								financialPlanningPurchase();
							} else { // 非K计划
								requesetPoi();
							}

						} else {

							showToast("该优惠券最低" + mLowestAmount / 100 + "元起投");

						}

					} else if (amountMultiple > 0) {

						if (invest_i % (amountMultiple / 100) == 0) {

							if (invest_d * 100 - mAmount <= balance * 100) {

								if (!(discount_unused.getText().toString()
										.startsWith("该优惠券最低") && discount_unused
										.getText().toString().endsWith("元起投"))) {
									showTenderToLoadDialog("投资金额 "
											+ (int) (invest_d) + "元", loading);
									if ("401".equals(bidType)) { // K计划
										financialPlanningPurchase();
									} else { // 非K计划
										requesetPoi();
									}

								} else {

									showToast("该优惠券最低" + mLowestAmount / 100
											+ "元起投");

								}

							} else {

								showToast(R.string.not_sufficient_funds);

							}

						} else {

							showToast("投资金额需要是" + amountMultiple / 100 + "的整数倍");

						}

					}

				}

			} else {
				// 投标金额 - 抵现券金额 >= 账户余额
				// showToast(R.string.not_sufficient_funds);
				showNotSufficientFundsDialog();

			}
		} else { // 　未使用抵现券

			if (invest_d <= balance) {

				if (invest_i < lowestAmount / 100) {
					showToast("投资金额不得低于" + amountMultiple / 100 + "元");
				} else {

					if (amountMultiple == 0) {
						if (mType == -1) {
							showTenderToLoadDialog("投资金额 " + invest_str + "元",
									loading);
							if ("401".equals(bidType)) { // K计划
								financialPlanningPurchase();
							} else { // 非K计划
								requesetPoi();
							}
						} else {
							if (!(discount_unused.getText().toString()
									.startsWith("该优惠券最低") && discount_unused
									.getText().toString().endsWith("元起投"))) {
								showTenderToLoadDialog("投资金额 "
										+ (int) (invest_d) + "元", loading);
								if ("401".equals(bidType)) { // K计划
									financialPlanningPurchase();
								} else { // 非K计划
									requesetPoi();
								}

							} else {

								showToast("该优惠券最低" + mLowestAmount / 100
										+ "元起投");

							}
						}

					} else if (amountMultiple > 0) {

						if (invest_i % (amountMultiple / 100) == 0) {
							if (mType == -1) {
								showTenderToLoadDialog("投资金额 " + invest_str
										+ "元", loading);
								if ("401".equals(bidType)) { // K计划
									financialPlanningPurchase();
								} else { // 非K计划
									requesetPoi();
								}
							} else {
								if (!(discount_unused.getText().toString()
										.startsWith("该优惠券最低") && discount_unused
										.getText().toString().endsWith("元起投"))) {
									showTenderToLoadDialog("投资金额 "
											+ (int) (invest_d) + "元", loading);
									if ("401".equals(bidType)) { // K计划
										financialPlanningPurchase();
									} else { // 非K计划
										requesetPoi();
									}

								} else {

									showToast("该优惠券最低" + mLowestAmount / 100
											+ "元起投");

								}
							}

						} else {
							showToast("投资金额需要是" + amountMultiple / 100 + "的整数倍");
						}
					}
				}
			} else {
				showNotSufficientFundsDialog();
			}

		}

	}

	public void tenderLogic() {
		if (mAccountInfo != null && mAccountInfo.getWithholdAuth() != null) {
			if (mAccountInfo.getWithholdAuth().getWithdrawStatus() == 1
					&& mAccountInfo.getWithholdAuth().getIsWithholdAuth() == 0) {
				showSinaDialog();
			} else {
				SystemUtils.onEvent("Regular_BidPage_Bid", 1);
				if ("501".equals(bidType)) {
					// 　bidType=501，快快享福；bidType = 其它，非快快享福；
					tenderExperience();
				} else {
					// 非快快享福
					tenderNonExperience();
				}
			}
		}
	}

	/**
	 * 选择优惠券
	 */
	public void selectDiscount() {

		// if (!"不使用优惠券".equals(discountName)) {
		//
		// if (mType == 1) { // 抵现券
		//
		// discount_img.setImageResource(R.drawable.deposit_img);
		//
		// } else if (mType == 2) { // 加息券
		//
		// discount_img.setImageResource(R.drawable.raise_img);
		//
		// } else if (mType == 3) { // 返现券
		//
		// discount_img.setImageResource(R.drawable.negative_img);
		//
		// }
		//
		// }

		updateFlag = true;

		if ("不使用优惠券".equals(discountName)) { // 不使用优惠券

			notUseCoupon();

		} else { // 使用优惠券

			useCoupons();

		}
	}

	/******** 不使用优惠券 *************/
	public void notUseCoupon() {

		show_dis.setVisibility(View.GONE);

		display1.setText("");

		display2.setText("");

		interestRate();
		discount_tv.setText(mDataList.size() + "张可用");
		discount_tv.setVisibility(View.GONE);
		rel_cancelCoupon.setVisibility(View.GONE);
		discount_tv.setTextColor(TenderAffirmActivity.this.getResources()
				.getColor(R.color.white));
		tv_tip.setText("共" + mDataList.size() + "张可用");
		discount_unused.setText("未使用");
		rel_tip.setVisibility(View.GONE);
		discount_unused.setVisibility(View.VISIBLE);
		linear_can_tip.setVisibility(View.GONE);
		discount_tv.setBackgroundResource(R.drawable.discountimg_bg_hui);
		// discount_unused.setTextColor(TenderAffirmActivity.this.getResources()
		// .getColor(R.color.gray_999999));

		mCouponId = "";

		mAmount = 0;

		earnings = "";

		if ("".equals(earnings)) {

			predict_ed.setText(df.format((int) (predict * 100) * 0.01));

		} else {

			predict_ed.setText(df.format(Double.parseDouble(df
					.format((int) (predict * 100) * 0.01))
					+ Double.parseDouble(earnings)));

		}

		// rise_tv.setText(bidInterest + "%");
		//
		// rise_tv.setTextColor(TenderAffirmActivity.this.getResources().getColor(
		// R.color.orange_ff7301));

		mId = -3;

		// discount_img.setImageResource(R.drawable.complete_img);

	}

	/********** 使用优惠券 ***************/
	public void useCoupons() {

		show_dis.setVisibility(View.GONE);// 改过
		if (isRegular) {
			rel_tip.setVisibility(View.VISIBLE);
		}
		discount_tv.setVisibility(View.VISIBLE);
		rel_cancelCoupon.setVisibility(View.VISIBLE);
		tv_tip.setText("已选1张,共" + mDataList.size() + "张可用");
		if (TextUtils.isEmpty(invest_ed.getText().toString())) { // 输入金额为空

			inputAmountIsEmpty();

		} else { // 输入金额不为空

			inputAmountNotEmpty();

		}
	}

	/********** 输入金额为空 *************/
	public void inputAmountIsEmpty() {

		discount_tv.setText(Title);
		if (mType == 2) {
			interestRate();
			// rise_tv.setText(bidInterest + "%");
			// rise_tv.setTextColor(TenderAffirmActivity.this.getResources()
			// .getColor(R.color.orange_ff7301));
			discount_unused.setText("该优惠券最低" + mLowestAmount / 100 + "元起投");
			discount_unused.setVisibility(View.VISIBLE);
			linear_can_tip.setVisibility(View.GONE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg_hui);
			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.green_a5a5a5));
		} else if (mType == 3) {
			interestRate();
			// rise_tv.setText(bidInterest + "%");
			// rise_tv.setTextColor(TenderAffirmActivity.this.getResources()
			// .getColor(R.color.orange_ff7301));
			discount_unused.setText("该优惠券最低" + mLowestAmount / 100 + "元起投");
			discount_unused.setVisibility(View.VISIBLE);
			linear_can_tip.setVisibility(View.GONE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg_hui);
			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.green_a5a5a5));
		} else {
			interestRate();
			// rise_tv.setText(bidInterest + "%");
			// rise_tv.setTextColor(TenderAffirmActivity.this.getResources()
			// .getColor(R.color.orange_ff7301));
			discount_unused.setText("该优惠券最低" + mLowestAmount / 100 + "元起投");
			discount_unused.setVisibility(View.VISIBLE);
			linear_can_tip.setVisibility(View.GONE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg_hui);
			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.green_a5a5a5));
		}
		display.setText("该优惠券最低起投金额为" + mLowestAmount / 100 + "元");
		display.setTextColor(TenderAffirmActivity.this.getResources().getColor(
				R.color.orange_ff6009));

	}

	/*********** 输入金额不为空 *************/
	public void inputAmountNotEmpty() {

		if (mType == 2) { // 加息券

			interestRateCoupon();

		} else if (mType == 3) { // 返现券

			returnXianquan();

		} else { // 抵现券

			toSpot();

		}
	}

	/************ 加息券 ***************/
	public void interestRateCoupon() {
		if (Integer.parseInt(invest_ed.getText().toString()) >= mLowestAmount / 100) {

			discount_tv.setText(Title);

			discount_tv.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.white));

			discount_unused.setText("+" + mAmount * 0.01 + "%");

			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.orange_ff6009));
			discount_unused.setVisibility(View.GONE);
			linear_can_tip.setVisibility(View.VISIBLE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg);
			tv_can_tip_1.setText("预计收益增加");
			tv_can_tip_2
					.setText(df
							.format((int) (((mAmount * 0.01) / dbidInterest * Double.parseDouble(df
									.format((int) (predict * 100) * 0.01))) * 1000) / 10 * 0.01));
			tv_can_tip_3.setText("元");
			LogUtil.e("dbidInterest2", "" + dbidInterest);
			LogUtil.e("predict2", "" + predict);
			LogUtil.e("mAmount1", "" + mAmount * 0.01);

			double interest = (mAmount * 0.01)
					/ dbidInterest
					* Double.parseDouble(df
							.format((int) (predict * 100) * 0.01));

			LogUtil.e("(int) (interest * 1000)", "" + interest * 100);
			LogUtil.e("(int) (interest * 1000) * 0.01", ""
					+ (int) (interest * 1000) / 10 * 0.01);

			earnings = df.format((int) (interest * 1000) / 10 * 0.01);

			LogUtil.e("interest", "" + interest);

			LogUtil.e("earnings", "" + earnings);

			display.setText("已加息+" + mAmount * 0.01 + "%，预计收益增加");

			display.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.green_a5a5a5));

			display1.setText(earnings);

			display2.setText("元");
			if (!TextUtils.isEmpty(bidInterest)) {
				if (bidInterest.indexOf("+") == -1) {
					rise_tv.setText(Tools.intOrDouble(Double
							.parseDouble(bidInterest)) + "%");
					rise_tv1.setText("+"
							+ Tools.intOrDouble((double) (mAmount * 0.01))
							+ "%");
				} else {
					String[] bit = bidInterest.split("\\+");
					rise_tv.setText(Tools.intOrDouble(Double
							.parseDouble(bit[0])) + "%");
					rise_tv1.setText("+"
							+ Tools.intOrDouble(Double.parseDouble(bit[1]))
							+ "%+"
							+ Tools.intOrDouble((double) (mAmount * 0.01))
							+ "%");
				}
			}
			/*
			 * rise_tv.setText(bidInterest + "%"); rise_tv1.setText("+" +
			 * mAmount * 0.01 + "%");
			 */
			if ("".equals(earnings)) {

				predict_ed.setText(df.format((int) (predict * 100) * 0.01));

			} else {

				predict_ed.setText(df.format(Double.parseDouble(df
						.format((int) (predict * 100) * 0.01))
						+ Double.parseDouble(earnings)));
			}
		} else {
			if ("".equals(earnings)) {
				predict_ed.setText(df.format((int) (predict * 100) * 0.01));
			} else {
				predict_ed.setText(df.format(Double.parseDouble(df
						.format((int) (predict * 100) * 0.01))
						+ Double.parseDouble(earnings)));
			}
			discount_tv.setText(Title);
			// rise_tv.setText(bidInterest + "%");
			interestRate();
			display1.setText("");
			display2.setText("");
			discount_unused.setText("该优惠券最低" + mLowestAmount / 100 + "元起投");
			discount_unused.setVisibility(View.VISIBLE);
			linear_can_tip.setVisibility(View.GONE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg_hui);
			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.green_a5a5a5));
			display.setText("该优惠券最低起投金额为" + mLowestAmount / 100 + "元");
			display.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.orange_ff6009));
		}

	}

	/*********** 返现券 *************/
	public void returnXianquan() {
		if (Integer.parseInt(invest_ed.getText().toString()) >= mLowestAmount / 100) {
			discount_tv.setText(Title);
			discount_unused.setText("¥" + df3.format(mAmount * 0.01));
			discount_unused.setVisibility(View.GONE);
			linear_can_tip.setVisibility(View.VISIBLE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg);
			tv_can_tip_1.setText("投标成功，返现");
			tv_can_tip_2.setText(df3.format(mAmount * 0.01));
			tv_can_tip_3.setText("元");
			discount_tv.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.white));
			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.orange_ff6009));
			earnings = "";
			if ("".equals(earnings)) {
				predict_ed.setText(df.format((int) (predict * 100) * 0.01));
			} else {
				predict_ed.setText(df.format(Double.parseDouble(df
						.format((int) (predict * 100) * 0.01))
						+ Double.parseDouble(earnings)));
			}
			display.setText("投标成功，返现");
			display.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.green_a5a5a5));
			display1.setText("" + df.format(mAmount * 0.01));
			display2.setText("元");
			// rise_tv.setText(bidInterest + "%");
			interestRate();
		} else {
			earnings = "";
			if ("".equals(earnings)) {
				predict_ed.setText(df.format((int) (predict * 100) * 0.01));
			} else {
				predict_ed.setText(df.format(Double.parseDouble(df
						.format((int) (predict * 100) * 0.01))
						+ Double.parseDouble(earnings)));
			}
			discount_tv.setText(Title);
			// rise_tv.setText(bidInterest + "%");
			interestRate();
			display1.setText("");
			display2.setText("");
			discount_unused.setText("该优惠券最低" + mLowestAmount / 100 + "元起投");
			discount_unused.setVisibility(View.VISIBLE);
			linear_can_tip.setVisibility(View.GONE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg_hui);
			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.green_a5a5a5));
			display.setText("该优惠券最低起投金额为" + mLowestAmount / 100 + "元");
			display.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.orange_ff6009));
		}
	}

	/************ 抵现券 *************************/
	public void toSpot() {
		if (Integer.parseInt(invest_ed.getText().toString()) >= mLowestAmount / 100) {
			earnings = "";
			if ("".equals(earnings)) {
				predict_ed.setText(df.format((int) (predict * 100) * 0.01));
			} else {
				predict_ed.setText(df.format(Double.parseDouble(df
						.format((int) (predict * 100) * 0.01))
						+ Double.parseDouble(earnings)));
			}
			discount_tv.setText(Title);
			discount_tv.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.white));
			discount_unused.setText("-¥" + df3.format(mAmount * 0.01));
			discount_unused.setVisibility(View.GONE);
			linear_can_tip.setVisibility(View.VISIBLE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg);
			tv_can_tip_1.setText("实际支付");
			tv_can_tip_2.setText(df3.format(Integer.parseInt(invest_ed
					.getText().toString()) - mAmount * 0.01));
			tv_can_tip_3.setText("元");
			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.orange_ff6009));
			display.setText("已优惠" + df3.format(mAmount * 0.01) + "元，实际支付");
			display.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.green_a5a5a5));
			display1.setText(df3.format(Integer.parseInt(invest_ed.getText()
					.toString()) - mAmount * 0.01)
					+ "");
			display2.setText("元");
			// rise_tv.setText(bidInterest + "%");
			interestRate();
		} else {
			earnings = "";
			if ("".equals(earnings)) {
				predict_ed.setText(df.format((int) (predict * 100) * 0.01));
			} else {
				predict_ed.setText(df.format(Double.parseDouble(df
						.format((int) (predict * 100) * 0.01))
						+ Double.parseDouble(earnings)));
			}
			discount_tv.setText(Title);
			// rise_tv.setText(bidInterest + "%");
			interestRate();
			display1.setText("");
			display2.setText("");
			discount_unused.setText("该优惠券最低" + mLowestAmount / 100 + "元起投");
			discount_unused.setVisibility(View.VISIBLE);
			linear_can_tip.setVisibility(View.GONE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg_hui);
			// discount_unused.setTextColor(TenderAffirmActivity.this
			// .getResources().getColor(R.color.green_a5a5a5));
			display.setText("该优惠券最低起投金额为" + mLowestAmount / 100 + "元");
			display.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.orange_ff6009));
		}
	}

	/**
	 * 优惠券
	 */
	public void couponList() {
		if (!"501".equals(bidType)) { // 非体验标才请求优惠券接口
			KkdHttpMagager.getInstance().getMyDiscountManager(bidId, "",
					"" + businessType, "true", 1, 100, 0,
					MyDiscountCouponData.class, new HttpCallBack() {

						@Override
						public void onSuccess(int statusCode,
								Object responseBody) {
							MyDiscountCouponData mMyDiscountCouponData = (MyDiscountCouponData) responseBody;
							mDataList.clear();
							mDataList.addAll(mMyDiscountCouponData
									.getDataList());
							// mDataList = mMyDiscountCouponData.getDataList();
							if (mDataList.size() > 0) {
								// discount_tv.setText(mDataList.size() +
								// "张可用");
								// discount_tv
								// .setBackgroundResource(R.drawable.discountimg_bg);
								if (firstCoupon || couponErr || tenderContinue) {
									if (firstCoupon) {
										firstCoupon = false;
									}
									if (couponErr) {
										couponErr = false;
									}
									if (tenderContinue) {
										tenderContinue = false;
									}
									// 默认选择第一张优惠券------------------------------------
									mId = 0;
									Title = mDataList.get(0).getTitle();
									mAmount = mDataList.get(0).getAmount();
									mLowestAmount = mDataList.get(0)
											.getLowestAmount();
									mCouponId = mDataList.get(0).getCouponId();
									mType = mDataList.get(0).getType();
									discountName = Title;
									// 默认选择第一张优惠券------------------------------------
								}
								selectDiscount();
							} else {
								discount_tv.setText(R.string.coupon_null);
								discount_tv
										.setBackgroundResource(R.drawable.discountimg_bg_hui);
								discount_unused.setVisibility(View.INVISIBLE);
								// discount_unused
								// .setTextColor(TenderAffirmActivity.this
								// .getResources().getColor(
								// R.color.orange_ff6009));
								tv_tip.setText("共" + mDataList.size() + "张可用");
								discount_tv.setVisibility(View.GONE);
								rel_cancelCoupon.setVisibility(View.GONE);
								rel_tip.setVisibility(View.GONE);
								discountName = "不使用优惠券";
								selectDiscount();
							}
							if (REFRESHFLAG) {
								REFRESHFLAG = false;
								mScrollView.clearState();
							}
						}

						@Override
						public void onFailure(int statusCode, String desc) {
							showToast(desc);
							if (REFRESHFLAG) {
								REFRESHFLAG = false;
								mScrollView.clearState();
							}
						}
					});
		}
	}

	/**
	 * 
	 * 投标
	 */
	public void requesetPoi() {
		next_bt.setEnabled(false);

		int amount = Integer.valueOf(invest_ed.getText().toString()) * 100;
		KkdHttpMagager.getInstance().getTenderAffirmManager(mCouponId, bidId,
				amount, String.class, new HttpCallBack() {

					@Override
					public void onSuccess(int statusCode, Object responseBody) {
						next_bt.setEnabled(true);
						try {
							closeTenderToLoadDialog();
							String responseString = responseBody.toString();
							LogUtil.e("responseBody", responseString);
							JSONObject data = new JSONObject(responseString);
							repayment = data.getString("repaymentType");
							startInterest = data.getString("startInterest");
							poiId = data.getString("poiId");
							LogUtil.e("has", data.has("url") + "");
							if ("501".equals(bidType)) {
								showTiYanTenderSucceedResult();
							} else {
								showTenderSucceedResult();
							}
							PreferenceUtils.getInstance().setMyproperty(
									TenderAffirmActivity.this, "");
							PreferenceUtils.getInstance().setEveryDay(
									TenderAffirmActivity.this, "");
							if (!SystemUtils
									.isOldUser(TenderAffirmActivity.this)) {

								String cache = PreferenceUtils.getInstance()
										.getHomeData(TenderAffirmActivity.this);

								if (!TextUtils.isEmpty(cache)) {

									Gson gson = new Gson();

									Home home = gson
											.fromJson(cache, Home.class);

									if (home != null && home.getData() != null) {

										HomeData homeData = home.getData();
										homeData.setNewHandStatus(1);
										home.setData(homeData);
										PreferenceUtils
												.getInstance()
												.setHomeData(
														TenderAffirmActivity.this,
														gson.toJson(home));
									}
								}
							}
						} catch (JSONException e) {
							e.printStackTrace();
						}

					}

					@Override
					public void onFailure(int statusCode, String desc) {
						next_bt.setEnabled(true);
						showTenderBeDefeatedResult(statusCode, desc);
						closeTenderToLoadDialog();
					}
				});
	}

	/****
	 * K计划购买
	 */
	public void financialPlanningPurchase() {
		next_bt.setEnabled(false);

		int amount = Integer.valueOf(invest_ed.getText().toString()) * 100;
		KkdHttpMagager.getInstance().getFinancialPlanningTenderAffirm(
				mCouponId, bidId, amount, String.class, new HttpCallBack() {

					@Override
					public void onSuccess(int statusCode, Object responseBody) {
						next_bt.setEnabled(true);
						try {
							closeTenderToLoadDialog();
							String responseString = responseBody.toString();
							LogUtil.e("responseBody", responseString);
							JSONObject data = new JSONObject(responseString);
							repayment = data.getString("repaymentType");
							startInterest = data.getString("startInterest");
							poiId = data.getString("poiId");
							LogUtil.e("has", data.has("url") + "");
							if ("501".equals(bidType)) {
								showTiYanTenderSucceedResult();
							} else {
								showTenderSucceedResult();
							}
						} catch (JSONException e) {
							e.printStackTrace();
						}

					}

					@Override
					public void onFailure(int statusCode, String desc) {
						next_bt.setEnabled(true);
						showTenderBeDefeatedResult(statusCode, desc);
						closeTenderToLoadDialog();
					}
				});
	}

	@Override
	protected void onResume() {
		super.onResume();
		if (succeedDialog != null) {
			succeedDialog.cancel();
			succeedDialog = null;
		}
		if ("401".equals(bidType)) { // K计划
			requestInterface();
		} else { // 非K计划
			requestParticulars();
		}
		couponList();
		if (PreferenceUtils.getInstance().getLogin(this) == 0) {
			getAccountInfo();
		}
	}

	/**
	 * 
	 * 查询账户余额
	 */
	public void getAccountInfo() {

		if (loadDialog != null) {
			loadDialog.cancel();
			loadDialog = null;
		}
		loadDialog = DialogUtils.toLoadDialog(this, "加载中...");
		KkdHttpMagager.getInstance().getAccountInfoManager(
				AccountInfoRes.class, new HttpCallBack() {

					@Override
					public void onSuccess(int statusCode, Object responseBody) {
						mAccountInfo = (AccountInfoRes) responseBody;

						DecimalFormat df = new DecimalFormat("0.00");
						balance = mAccountInfo.getBalance();// .getDouble("balance");
						if ("501".equals(bidType)) { // 体验标
							experiencePrincipal = mAccountInfo
									.getExperiencePrincipal();
							if (experiencePrincipal >= lowestAmount / 100) {
								whole_bt.setTextColor(Color
										.parseColor("#6c54b6"));
								whole_bt.setClickable(true);
								LogUtil.e("TAG", "大于");
							} else {
								whole_bt.setTextColor(Color
										.parseColor("#c2c2c2"));
								whole_bt.setClickable(false);
								LogUtil.e("TAG", "小于");
							}
						} else {
							if (balance >= lowestAmount / 100) {
								whole_bt.setTextColor(Color
										.parseColor("#6c54b6"));
								whole_bt.setClickable(true);
								LogUtil.e("TAG", "大于");
							} else {
								whole_bt.setTextColor(Color
										.parseColor("#c2c2c2"));
								whole_bt.setClickable(false);
								LogUtil.e("TAG", "小于");
							}
						}
						bmouts = df.format(balance);
						mHandler.sendEmptyMessage(ACCOUNTINFO_CODE_ZERO);
						balance_tv1.setText("" + bmouts);
						// ---------------------------
						if ("501".equals(bidType)) {
							experiencePrincipal = mAccountInfo
									.getExperiencePrincipal();
							String experiencePrincipal_format = df
									.format(experiencePrincipal);
							balance_tv1
									.setText("" + experiencePrincipal_format);
							rel_new_task.setVisibility(View.GONE);
						} else {
							/*
							 * 判断是否处于新手任务阶段和首投阶段
							 */
							newMisTips = mAccountInfo.getNewMisTips()
									.getNewMisTips();
							maxTime = (int) (mAccountInfo.getNewMisTips()
									.getTimeSpace() / 1000);
							if (!TextUtils.isEmpty(newMisTips)) { // 说明处于新手任务阶段
								FirstPoiTipsData jsonObject_firstPoiTips = mAccountInfo
										.getFirstPoiTips();
								firstPoiTips1 = jsonObject_firstPoiTips
										.getFirstPoiTips1();
								firstPoiTips2 = jsonObject_firstPoiTips
										.getFirstPoiTips2();
								if (!TextUtils.isEmpty(firstPoiTips1)
										&& !TextUtils.isEmpty(firstPoiTips2)) {
									rel_new_task.setVisibility(View.VISIBLE);
									// tv_timespace_newtask.setText(newMisTips);
									tv_tip_black.setText(firstPoiTips1);
									tv_tip_orange.setText(firstPoiTips2);
									updateNewTaskSpaceTime();
									startTime();
								} else {
									rel_new_task.setVisibility(View.GONE);
								}
							} else {
								rel_new_task.setVisibility(View.GONE);
							}
						}

					}

					@Override
					public void onFailure(int statusCode, String desc) {
						Message msg = new Message();
						msg.what = ACCOUNTINFO_CODE_ELSE;
						msg.obj = desc;
						mHandler.sendMessage(msg);
					}
				});
	}

	class CountryAdapter extends AbstractWheelTextAdapter {

		List<String> mList;

		protected CountryAdapter(Context context, List<String> mList) {
			super(context);
			this.mList = mList;
		}

		@Override
		public int getItemsCount() {
			return mList.size();
		}

		@Override
		protected CharSequence getItemText(int index) {
			return mList.get(index);
		}
	}

	public void showTokeOutDialog() {
		if (mDialog != null) {
			mDialog.cancel();
			mDialog = null;
		}
		mDialog = DialogUtils.getTenderAffirmDialog(this,
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						switch (v.getId()) {
						case R.id.close_rl:
							SystemUtils.onEvent("Regular_Result_CloseLotteryn",
									1);
							mDialog.dismiss();
							mDialog = null;
							break;
						case R.id.luck_draw:
							if (!TextUtils.isEmpty(url)) {
								SystemUtils.onEvent(
										"Regular_Result_GotoLotteryn", 1);
								Intent intent = new Intent(
										TenderAffirmActivity.this,
										KKDWebActivity.class);
								intent.putExtra("url", url);
								startActivity(intent);
							}
							finish();
							mDialog.dismiss();
							mDialog = null;
							break;
						}
					}
				});
		mDialog.show();
	}

	/******
	 * 
	 * 非K计划详情接口
	 * 
	 *****/
	public void requestParticulars() {

		KkdHttpMagager.getInstance().getParticularsManager(bidId,
				ParticularsData.class, new HttpCallBack() {

					@Override
					public void onSuccess(int statusCode, Object responseBody) {
						ParticularsData data = (ParticularsData) responseBody;

						bidFreeAmount = data.getBidFreeAmount();
						String sbidFreeAmount = df2
								.format(bidFreeAmount * 0.01);
						procedure_tv1.setText("" + sbidFreeAmount);
					}

					@Override
					public void onFailure(int statusCode, String desc) {
						showToast(desc);
					}
				});
	}

	/*********
	 * K计划详情接口
	 *********/
	public void requestInterface() {
		KkdHttpMagager.getInstance().financialPlanningDetails(bidId,
				FinancialPlanningData.class, new HttpCallBack() {

					@Override
					public void onSuccess(int statusCode, Object responseBody) {
						FinancialPlanningData data = (FinancialPlanningData) responseBody;
						FinanceDto financeDto = data.getFinanceDto();
						bidFreeAmount = financeDto.getLeftAmount();
						String sbidFreeAmount = df2
								.format(bidFreeAmount * 0.01);
						procedure_tv1.setText("" + sbidFreeAmount);
					}

					@Override
					public void onFailure(int statusCode, String desc) {
					}
				});
	}

	// 投标成功活动
	public void tenderAffirmCampaign() {
		double tenderAmout = Double.parseDouble(invest_ed.getText().toString());
		String customerIdAndToken = PreferenceUtils.getInstance()
				.getcustomerId(this);
		final String[] cat = customerIdAndToken.split("&");
		KkdHttpMagager.getInstance().tenderAffirmCampaign(poiId,
				(long) tenderAmout * 100, productType, new HttpCallBack() {

					@Override
					public void onSuccess(int statusCode, Object responseBody) {
						try {
							String reponString = responseBody.toString();
							final JSONObject data = new JSONObject(reponString);
							boolean popUp = data.optBoolean("popUp");
							final int isLuckyFlag = data.optInt("isLuckyFlag");
							String mis_succ_image = data
									.optString("mis_succ_image");// 是否首投开启特权
							if (isLuckyFlag == 1) {
								String luckyUrl = data.getString("luckyUrl");
								url = luckyUrl + "&customerId=" + cat[1]
										+ "&token=" + cat[0]
										+ "&channel=Android";
								if (succeedDialog != null
										&& succeedDialog.isShowing()) {
									succeedDialog.findViewById(
											R.id.draw_lottery_rl)
											.setVisibility(View.VISIBLE);

								}
								// showTokeOutDialog();
							}
							if (TextUtils.isEmpty(mis_succ_image)) {// 说明不是首投，走以前的逻辑
								if (popUp) {
									// 签到完成状态，0未完成，1完成；
									int signInStatus = data
											.getInt("signInStatus");
									// 签到获取快乐币个数
									int signInCionSum = data
											.getInt("signInCionSum");
									// 签到优惠券金额
									long signIncouponAmount = data
											.getLong("signIncouponAmount");
									// 连续签到天数
									int days = data.getInt("days");
									// 分享邀请好友获得快乐币个数
									int inviteCionSum = data
											.getInt("inviteCionSum");
									// 0未完成，1完成；
									int inviteStatus = data
											.getInt("inviteStatus");
									// 投资完成状态，0未完成，1完成；
									int poiStatus = data.getInt("poiStatus");
									// 投资奖励快乐币个数
									int poiCionSum = data.getInt("poiCionSum");
									// 投资任务未完成提示最高奖励快乐币个数
									int poiMoreCionSum = data
											.getInt("poiMoreCionSum");
									// 邀请好友攻略Url
									String inviteStrategyUrl = data
											.getString("inviteStrategyUrl");
									// 快乐币任务全部完成获取快乐币总数
									int doubleAllSum = data
											.getInt("doubleAllSum");
									// 完成快乐币任务排名
									int customerSeat = data
											.getInt("customerSeat");
									// 完成任务获得快乐币个数
									int doubleSum = data.getInt("doubleSum");
									// 完成快乐币任务翻倍的倍率
									String doubleRate = data
											.getString("doubleRate");
									// 翻倍获取快乐币个数
									int doubleMisSum = data
											.getInt("doubleMisSum");
									// 快乐币任务url
									String coinMisUrl = data
											.getString("coinMisUrl");
									// 是否可以补签 0：不可以，1：可以
									int isRepairSigninStatus = data
											.getInt("isRepairSigninStatus");
									happyCoinCompleteProgressDialog(
											signInStatus, signInCionSum,
											signIncouponAmount, days,
											inviteCionSum, inviteStatus,
											poiStatus, poiCionSum,
											poiMoreCionSum, inviteStrategyUrl,
											doubleAllSum, customerSeat,
											doubleSum, doubleRate,
											doubleMisSum, coinMisUrl,
											isRepairSigninStatus);
								}
							} else {
								if (dialog_finishShoutou != null) {
									dialog_finishShoutou.cancel();
									dialog_finishShoutou = null;
								}
								final String moneyTreeUrl = data
										.optString("moneyTreeUrl");
								dialog_finishShoutou = DialogUtils
										.finishXinshouShoutouDialog(
												TenderAffirmActivity.this,
												mis_succ_image,
												new OnSingleClickListener() {

													@Override
													public void onSingleClick(
															View v) {
														if (dialog_finishShoutou != null) {
															dialog_finishShoutou
																	.cancel();
														}
														if (!TextUtils
																.isEmpty(moneyTreeUrl)) {
															Intent intent = new Intent(
																	TenderAffirmActivity.this,
																	KKDWebActivity.class);
															intent.putExtra(
																	"url",
																	moneyTreeUrl
																			+ "&customerId="
																			+ cat[1]
																			+ "&token="
																			+ cat[0]
																			+ "&channel=Android");
															startActivity(intent);
														}
													}
												});
								dialog_finishShoutou.show();
							}
						} catch (JSONException e) {
							e.printStackTrace();
						}
					}

					@Override
					public void onFailure(int statusCode, String desc) {

					}
				}, String.class);
	}

	/****** 账户余额不足对话框 ************/
	public void showNotSufficientFundsDialog() {
		if (nsfDialog != null) {
			nsfDialog.cancel();
			nsfDialog = null;
		}
		nsfDialog = DialogUtils.notSufficientFundsDialog(this,
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						switch (v.getId()) {
						case R.id.cancel_tv: // 取消
							nsfDialog.dismiss();
							break;
						case R.id.recharge_tv: // 充值

							SystemUtils.onEvent(
									"Regular_BidPage_Windows_Recharge", 1);
							AuthenticationUtils.getAuthenticationResult(
									TenderAffirmActivity.this, 3,
									RechargeActivity.class);
							nsfDialog.dismiss();
							break;
						}

					}
				}, true);
		nsfDialog.show();
	}

	/***** 投标等待Dialog *********/
	public void showTenderToLoadDialog(String content, String loading) {
		if (tenderDialog != null) {
			tenderDialog.cancel();
			tenderDialog = null;
		}
		tenderDialog = DialogUtils.tendertoLoadDialog(this, content, loading);
		tenderDialog.show();
	}

	/******** 关闭投标等待Dialog ******/
	public void closeTenderToLoadDialog() {
		if (tenderDialog != null) {
			if (tenderDialog.isShowing())
				tenderDialog.dismiss();
			tenderDialog.cancel();
			tenderDialog = null;
		}
	}

	/********* 定期投标成功结果 *************/
	public void showTenderSucceedResult() {
		double tenderAmout = 0;
		String bidDeadline = "";
		if (succeedDialog != null) {
			succeedDialog.cancel();
			succeedDialog = null;
		}
		tenderAmout = Double.parseDouble(invest_ed.getText().toString());
		if ("天".equals(bidPeriodType)) {
			bidDeadline = bidPeriodType;
		} else if ("月".equals(bidPeriodType)) {
			bidDeadline = "个" + bidPeriodType;
		}
		String button_tv = "";
		String expectedInterest = "开始计息";
		if ("501".equals(bidType)) {
			button_tv = "查看我的快快享福投资";
		} else if ("401".equals(bidType)) {
			expectedInterest = "预计计息";
			button_tv = "查看我的K计划";
		} else {
			button_tv = "查看我的定期投资";
		}
		String continue_bt_tx = "查看我的定期投资";
		boolean examineFlag = true;
		if ("401".equals(bidType)) {
			continue_bt_tx = "继续投资";
		} else {
			if (isNewbie == 1) {
				continue_bt_tx = "查看我的定期投资";
				examineFlag = false;
			} else {
				continue_bt_tx = "继续投标";
				examineFlag = true;
			}
		}

		String title = "投标成功";
		if ("401".equals(bidType)) {
			title = "购买成功";
		} else {
			title = "投标成功";
		}
		String expected_return = predict_ed.getText().toString();
		Intent intent = new Intent(this, TreatySucceedActivity.class);
		intent.putExtra("poiId", poiId);
		intent.putExtra("productType", productType);
		intent.putExtra("tenderAmout", tenderAmout);
		intent.putExtra("title", title);
		intent.putExtra("continue_bt_tx", continue_bt_tx);
		intent.putExtra("examineFlag", examineFlag);
		intent.putExtra("button_tv", button_tv);
		intent.putExtra("bidName", bidTitle);
		intent.putExtra("tenderAmoutStr", df1.format(tenderAmout));
		intent.putExtra("bidPeriodAdd", bidPeriodAdd);
		intent.putExtra("bidDeadline", bidPeriod);
		intent.putExtra("bidDeadline_company", bidDeadline);
		intent.putExtra("repayment", repayment);
		intent.putExtra("expected_return", expected_return);
		intent.putExtra("startInterest", startInterest);
		intent.putExtra("expectedInterest", expectedInterest);
		startActivityForResult(intent, JUMP_REGULAR_SUCCESS);
		// succeedDialog = DialogUtils.tenderSucceedResult(this, title,
		// examineFlag, continue_bt_tx, bidTitle, df1.format(tenderAmout),
		// bidPeriod, bidDeadline, expected_return, repayment,
		// startInterest, bidPeriodAdd, new OnClickListener() {
		//
		// @Override
		// public void onClick(View v) {
		// switch (v.getId()) {
		// case R.id.result_title_img: // 返回
		// succeedDialog.dismiss();
		//
		// SystemUtils.onEvent("Regular_Result_Back", 1);
		// finish();
		// break;
		// case R.id.examine: // 　查看记录
		//
		// if ("501".equals(bidType)) {
		// SystemUtils.onEvent(
		// "Expericence_Result_CheckRecord", 1);
		// Intent intent = new Intent(
		// TenderAffirmActivity.this,
		// MyExperienceGoldActivity.class);
		// startActivity(intent);
		// succeedDialog.dismiss();
		// } else if ("401".equals(bidType)) {
		// SystemUtils.onEvent(
		// "Regular_Result_CheckRecord", 1);
		// Intent intent = new Intent(
		// TenderAffirmActivity.this,
		// MyPlanActivity.class);
		// startActivity(intent);
		// succeedDialog.dismiss();
		// } else {
		// SystemUtils.onEvent(
		// "Regular_Result_CheckRecord", 1);
		// Intent intent = new Intent(
		// TenderAffirmActivity.this,
		// MyRegularActivity.class);
		// startActivity(intent);
		// succeedDialog.dismiss();
		// }
		// finish();
		// break;
		// case R.id.continue_bt: // 继续投标
		// if (isNewbie == 1) {
		// SystemUtils.onEvent(
		// "Regular_Result_CheckRecord", 1);
		// Intent intent = new Intent(
		// TenderAffirmActivity.this,
		// MyRegularActivity.class);
		// startActivity(intent);
		// succeedDialog.dismiss();
		// finish();
		// } else {
		// if (!"不使用优惠券".equals(discountName)) {
		// tenderContinue = true;
		// }
		// if ("401".equals(bidType)) { // K计划
		// requestInterface();
		// } else { // 非K计划
		// requestParticulars();
		// }
		// couponList();
		// getAccountInfo();
		// invest_ed.setText("");
		// show_dis.setVisibility(View.GONE);
		// display1.setText("");
		// display2.setText("");
		// interestRate();
		// discount_tv.setText(mDataList.size() + "张可用");
		// discount_tv
		// .setTextColor(TenderAffirmActivity.this
		// .getResources().getColor(
		// R.color.white));
		// discount_unused.setText("未使用");
		// discount_unused.setVisibility(View.VISIBLE);
		// linear_can_tip.setVisibility(View.GONE);
		// discount_tv
		// .setBackgroundResource(R.drawable.discountimg_bg_hui);
		// // discount_unused
		// // .setTextColor(TenderAffirmActivity.this
		// // .getResources().getColor(
		// // R.color.gray_999999));
		// interestRate();
		// discountName = "不使用优惠券";
		// mCouponId = "";
		// mType = -1;
		// succeedDialog.dismiss();
		// }
		// break;
		// case R.id.draw_lottery_rl: // 摇奖
		// LogUtil.e("TAG", "------->摇一摇");
		// // // 设置粒子扩散效果
		// // ParticleSystem particleSystem = new
		// // ParticleSystem(
		// // TenderAffirmActivity.this, 10,
		// // R.drawable.sign, 800);
		// // particleSystem
		// // .setContext(TenderAffirmActivity.this);
		// // particleSystem
		// // .setSpeedRange(0.025f, 0.045f)
		// // .oneShot(
		// // succeedDialog
		// // .findViewById(R.id.shake_icon),
		// // 50);
		//
		// SystemUtils.onEvent("Regular_Result_GotoLotteryn",
		// 1);
		// Intent intent = new Intent(
		// TenderAffirmActivity.this,
		// KKDWebActivity.class);
		// intent.putExtra("url", url);
		// startActivity(intent);
		// succeedDialog.dismiss();
		// finish();
		// break;
		// }
		// }
		// }, button_tv);
		// succeedDialog.setOnKeyListener(new OnKeyListener() {
		//
		// @Override
		// public boolean onKey(DialogInterface dialog, int keyCode,
		// KeyEvent event) {
		// if (keyCode == KeyEvent.KEYCODE_BACK) {
		// if (succeedDialog != null) {
		// if (succeedDialog.isShowing()) {
		// succeedDialog.dismiss();
		// TenderAffirmActivity.this.finish();
		// return true;
		// }
		// }
		// }
		// return false;
		// }
		// });
		// succeedDialog.show();
		// tenderAffirmCampaign();
	}

	// 快快享福投标成功结果
	public void showTiYanTenderSucceedResult() {

		double tenderAmout = 0;
		String bidDeadline = "";
		if (succeedDialog != null) {
			succeedDialog.cancel();
			succeedDialog = null;
		}
		tenderAmout = Double.parseDouble(invest_ed.getText().toString());
		if ("天".equals(bidPeriodType)) {
			bidDeadline = bidPeriodType;
		} else if ("月".equals(bidPeriodType)) {
			bidDeadline = "个" + bidPeriodType;
		}
		String expected_return = predict_ed.getText().toString();
		Intent intent = new Intent(this, ToEnjoyTenderSuccessActivity.class);
		intent.putExtra("bidName", bidTitle);
		intent.putExtra("tenderAmoutStr", df1.format(tenderAmout));
		intent.putExtra("bidDeadline", bidPeriod);
		intent.putExtra("bidDeadline_company", bidDeadline);
		intent.putExtra("expected_return", expected_return);
		intent.putExtra("repayment", repayment);
		intent.putExtra("startInterest", startInterest);
		startActivityForResult(intent, KKXF_REGULAR_SUCCESS);
		// succeedDialog = DialogUtils.tenderSucceedResult(this, bidTitle,
		// df1.format(tenderAmout), bidPeriod, bidDeadline,
		// expected_return, repayment, startInterest,
		// new OnClickListener() {
		//
		// @Override
		// public void onClick(View v) {
		// switch (v.getId()) {
		// case R.id.result_title_img: // 返回
		// succeedDialog.dismiss();
		//
		// SystemUtils.onEvent("Regular_Result_Back", 1);
		// finish();
		// break;
		// case R.id.examine: // 　查看记录
		//
		// if ("501".equals(bidType)) {
		// SystemUtils.onEvent(
		// "Expericence_Result_CheckRecord", 1);
		// Intent intent = new Intent(
		// TenderAffirmActivity.this,
		// MyExperienceGoldActivity.class);
		// startActivity(intent);
		// succeedDialog.dismiss();
		// } else {
		// SystemUtils.onEvent(
		// "Regular_Result_CheckRecord", 1);
		// Intent intent = new Intent(
		// TenderAffirmActivity.this,
		// MyRegularActivity.class);
		// startActivity(intent);
		// succeedDialog.dismiss();
		// }
		// finish();
		// break;
		// case R.id.draw_lottery_rl: // 摇奖
		// SystemUtils.onEvent("Regular_Result_GotoLotteryn",
		// 1);
		// Intent intent = new Intent(
		// TenderAffirmActivity.this,
		// KKDWebActivity.class);
		// intent.putExtra("url", url);
		// startActivity(intent);
		// succeedDialog.dismiss();
		// finish();
		// break;
		// }
		// }
		// });
		// succeedDialog.setOnKeyListener(new OnKeyListener() {
		//
		// @Override
		// public boolean onKey(DialogInterface dialog, int keyCode,
		// KeyEvent event) {
		// if (keyCode == KeyEvent.KEYCODE_BACK) {
		// if (succeedDialog != null) {
		// if (succeedDialog.isShowing()) {
		// succeedDialog.dismiss();
		// TenderAffirmActivity.this.finish();
		// return true;
		// }
		// }
		// }
		// return false;
		// }
		// });
		// succeedDialog.show();
		// tenderAffirmCampaign();

	}

	/********** 投标失败结果 ************/
	public void showTenderBeDefeatedResult(final int statusCode, String desc) {
		beDefeatedDialog = DialogUtils.tenderBeDefeatedResult(this, desc,
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						beDefeatedDialog.dismiss();
						if (statusCode == 555) { // 代表是优惠券不可用
							couponErr = true;
							couponList();
						}
						// else {
						// finish();
						// }
					}
				});
	}

	/*********** 更新界面数据 **************/
	public void updateData() {
		getAccountInfo();
		if ("401".equals(bidType)) { // K计划
			requestInterface();
		} else { // 非K计划
			requestParticulars();
		}
	}

	/***********
	 * 快乐币任务完成进度Dialog
	 ***********/
	public void happyCoinCompleteProgressDialog(int signInStatus,
			int signInCionSum, long signIncouponAmount, int signDays,
			int inviteCionSum, int inviteStatus, int poiStatus, int poiCionSum,
			int poiMoreCionSum, String inviteStrategyUrl, int doubleAllSum,
			int customerSeat, int doubleSum, String doubleRate,
			int doubleMisSum, String coinMisUrl, int isRepairSigninStatus) {
		if (happyCoinCompleteProgressDialog != null) {
			happyCoinCompleteProgressDialog.cancel();
			happyCoinCompleteProgressDialog = null;
		}
		happyCoinCompleteProgressDialog = DialogUtils
				.happyCoinCompleteProgressDialog(this, false, signInStatus,
						signInCionSum, signIncouponAmount, signDays, 3,
						inviteCionSum, inviteStatus, poiStatus, poiCionSum,
						poiMoreCionSum, inviteStrategyUrl, doubleAllSum,
						customerSeat, doubleSum, doubleRate, doubleMisSum,
						coinMisUrl, isRepairSigninStatus);
		happyCoinCompleteProgressDialog.show();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		/****** 账户余额不足对话框 ************/
		if (nsfDialog != null) {
			nsfDialog.cancel();
			nsfDialog = null;
		}
		/***** 投标等待Dialog *********/
		if (tenderDialog != null) {
			tenderDialog.cancel();
			tenderDialog = null;
		}
		/********* 投标成功结果 *************/
		if (succeedDialog != null) {
			succeedDialog.cancel();
			succeedDialog = null;
		}
		/********** 投标失败结果 ************/
		if (beDefeatedDialog != null) {
			beDefeatedDialog.cancel();
			beDefeatedDialog = null;
		}

		if (mTimerTask_newTask != null) {
			mTimerTask_newTask.cancel();
			mTimerTask_newTask = null;
		}
		if (mTimer != null) {
			mTimer.cancel();
			mTimer = null;
		}
		if (dialog_finishShoutou != null) {
			dialog_finishShoutou.cancel();
			dialog_finishShoutou = null;
		}

		if (happyCoinCompleteProgressDialog != null) {
			happyCoinCompleteProgressDialog.cancel();
			happyCoinCompleteProgressDialog = null;
		}

		if (loadDialog != null) {
			loadDialog.cancel();
			loadDialog = null;
		}
	}

	public int maxTime = 0;
	private int mRecordTime = 0;
	private boolean isRecoding = false;
	public static final int RECORD_TIMER = 8112;
	public static final int RECORD_DONE = 8113;
	public static final int RECORD_ERROR = 8114;
	public static final int PERIOD = 1000;
	private TimerTask mTimerTask_newTask = null;
	private Timer mTimer = new Timer();
	public TimerHandler mTimerHandler = new TimerHandler(this);

	public void updateNewTaskSpaceTime() {
		int dtime = maxTime - mRecordTime;
		int ss = dtime % 60;
		int mm = (dtime / 60) % 60;
		int hh = dtime / 60 / 60;
		String tip_time_newtask = "";
		if (hh < 1) { // 不足一小时
			tip_time_newtask = "新手任务将在" + mm + "分" + ss + "秒后结束";
		} else if (hh >= 1 && hh < 24) { // 小于一天大于1小时
			tip_time_newtask = "新手任务将在今天24时结束";
		} else if (hh >= 24) { // 大于一天
			tip_time_newtask = "新手任务将在" + hh / 24 + "天后结束";
		}
		tv_timespace_newtask.setText(tip_time_newtask);
	}

	public void onTimerFinish() {
		if (mTimerTask_newTask != null) {
			mTimerTask_newTask.cancel();
			mTimerTask_newTask = null;
		}
		if (mTimer != null) {
			mTimer.cancel();
			mTimer = null;
		}
		getAccountInfo();
	}

	public void startTime() {
		mRecordTime = 0;
		if (!isRecoding) {
			if (mTimerTask_newTask != null) {
				mTimerTask_newTask.cancel();
				mTimerTask_newTask = null;
			}
			if (mTimer != null) {
				mTimer.cancel();
				mTimer = null;
			}
			mTimerTask_newTask = new RecordTimeTask();
			mTimer = new Timer();
			mTimer.schedule(mTimerTask_newTask, 0, PERIOD);
		}

		isRecoding = true;

	}

	private class RecordTimeTask extends TimerTask {
		@Override
		public void run() {
			if (isRecoding) {
				mRecordTime++;
				if (mRecordTime <= maxTime) {
					Message message = new Message();
					message.what = RECORD_TIMER;
					message.obj = mRecordTime;
					mTimerHandler.sendMessage(message);
				} else {
					Message message = new Message();
					message.what = RECORD_DONE;
					message.arg1 = mRecordTime;
					message.obj = "";
					mTimerHandler.sendMessage(message);
					isRecoding = false;
				}
			}

		}
	}

	public static class TimerHandler extends Handler {
		WeakReference<TenderAffirmActivity> reference;

		public TimerHandler(TenderAffirmActivity activity) {
			reference = new WeakReference<TenderAffirmActivity>(activity);
		}

		@Override
		public void dispatchMessage(Message msg) {
			switch (msg.what) {
			case RECORD_TIMER:
				if (reference != null && reference.get() != null)
					reference.get().updateNewTaskSpaceTime();
				break;
			case RECORD_DONE:
				if (reference != null && reference.get() != null)
					reference.get().onTimerFinish();
				break;
			default:
				break;
			}
		}
	}

	protected void showSinaDialog() {
		if (mSinaDialog != null) {
			mSinaDialog.cancel();
			mSinaDialog = null;
		}
		try {
			String text = "";

			if (mAccountInfo.getWithholdAuth().getIsSinaPayPassword() == 0) {
				text = mAccountInfo.getWithholdAuth().getPayPasswordTips();
			} else if (mAccountInfo.getWithholdAuth().getIsWithholdAuth() == 0) {
				text = mAccountInfo.getWithholdAuth().getWithholdAuthTips();
			}
			if (!TextUtils.isEmpty(text)) {
				mSinaDialog = DialogUtils.generate2BDialog(this, text, "去设置",
						"再看看", new OnClickListener() {

							@Override
							public void onClick(View v) {
								mSinaDialog.dismiss();
								Intent intent = new Intent(
										TenderAffirmActivity.this,
										KKDSinaWebActivity.class);
								intent.putExtra("url", mAccountInfo
										.getWithholdAuth()
										.getSinaWithholdAuthUrl());
								intent.putExtra("useTitleName", true);
								intent.putExtra("titleName", "新浪支付");
								startActivityForResult(intent,
										KKDSinaWebActivity.SET_PWD);
							}
						}, new OnClickListener() {

							@Override
							public void onClick(View v) {
								mSinaDialog.dismiss();
								finish();
							}
						});
				mSinaDialog.show();
			}
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);

		// 　选择优惠券 请求码和结果码 resultCode == 600 不使用优惠券；resultCode == 700 使用优惠券
		if (requestCode == 50 && resultCode == 600) {
			discountName = "不使用优惠券";
			selectDiscount();
		} else if (requestCode == 50 && resultCode == 700) {

			// 选中的优惠券的优惠券信息
			mId = data.getIntExtra("mId", -2);
			MyDiscountCouponDataList mMyDiscountCouponDataList = (MyDiscountCouponDataList) data
					.getSerializableExtra("seri");
			Title = mMyDiscountCouponDataList.getTitle();
			mAmount = mMyDiscountCouponDataList.getAmount();
			mLowestAmount = mMyDiscountCouponDataList.getLowestAmount();
			mCouponId = mMyDiscountCouponDataList.getCouponId();
			mType = mMyDiscountCouponDataList.getType();
			discountName = Title;
			selectDiscount();
		} else if (requestCode == KKDSinaWebActivity.SET_PWD) {
			if (resultCode == KKDSinaWebActivity.SET_PWD_SUCCESS) {

			} else {
				showSinaDialog();
			}
		}

		if (requestCode == JUMP_REGULAR_SUCCESS) { // 跳转定期投标成功请求码
			if (resultCode == TreatySucceedActivity.CLOSE_RESULT_CODE) { // 定期投标摇奖返回结果码
				finish();
			} else if (resultCode == TreatySucceedActivity.CONTINUE_CODE) { // 定期投标继续投标返回结果码
				continuedBid(); // 定期继续投标
			} else if (resultCode == TreatySucceedActivity.VIEW_RECORD_CODE) { // 定期投标查看记录返回结果码
				viewRecord();
			} else if (resultCode == TreatySucceedActivity.RETURN_CODE) { // 定期投标完成返回结果码
				SystemUtils.onEvent("Regular_Result_Back", 1);
				finish();
			} else if (resultCode == TreatySucceedActivity.BACK_CODE) { // 定期投标back键返回结果码
				finish();
			}
		}

		if (requestCode == KKXF_REGULAR_SUCCESS) { // 跳转快快享福投标成功请求码
			if (resultCode == ToEnjoyTenderSuccessActivity.TOENJOY_RETURN_CODE) { // 快快享福投标完成返回结果码
				finish();
			} else if (resultCode == ToEnjoyTenderSuccessActivity.TOENJOY_VIEW_RECORD_CODE) { // 定期投标查看记录返回结果码
				toEnjoyviewRecord();
			} else if (resultCode == ToEnjoyTenderSuccessActivity.TOENJOY_CLOSE_RESULT_CODE) { // 快快享福投标摇奖返回结果码
				finish();
			} else if (resultCode == ToEnjoyTenderSuccessActivity.TOENJOY_BACK_CODE) { // 快快享福投标back键返回结果码
				finish();
			}
		}

	}

	// 定期继续投标
	public void continuedBid() {
		if (isNewbie == 1) { // 是新手标跳转我的定期
			SystemUtils.onEvent("Regular_Result_CheckRecord", 1);
			Intent intent = new Intent(TenderAffirmActivity.this,
					MyRegularDebtActivity.class);
			startActivity(intent);
			finish();
		} else { // 非新手标，继续投标

			if (!"不使用优惠券".equals(discountName)) {
				tenderContinue = true;
			}
			if ("401".equals(bidType)) { // K计划
				requestInterface();
			} else { // 非K计划
				requestParticulars();
			}
			couponList();
			getAccountInfo();
			invest_ed.setText("");
			show_dis.setVisibility(View.GONE);
			display1.setText("");
			display2.setText("");
			interestRate();
			discount_tv.setText(mDataList.size() + "张可用");
			discount_tv.setTextColor(TenderAffirmActivity.this.getResources()
					.getColor(R.color.white));
			discount_unused.setText("未使用");
			discount_unused.setVisibility(View.VISIBLE);
			linear_can_tip.setVisibility(View.GONE);
			discount_tv.setBackgroundResource(R.drawable.discountimg_bg_hui);
			interestRate();
			discountName = "不使用优惠券";
			mCouponId = "";
			mType = -1;
		}
	}

	// 定期投标查看记录
	public void viewRecord() {
		if ("501".equals(bidType)) { // 特权本金（体验标&&快快享福）
			SystemUtils.onEvent("Expericence_Result_CheckRecord", 1);
			Intent intent = new Intent(TenderAffirmActivity.this,
					MyExperienceGoldActivity.class);
			startActivity(intent);
		} else if ("401".equals(bidType)) { // K计划
			SystemUtils.onEvent("Regular_Result_CheckRecord", 1);
			Intent intent = new Intent(TenderAffirmActivity.this,
					MyPlanActivity.class);
			startActivity(intent);
		} else {
			SystemUtils.onEvent("Regular_Result_CheckRecord", 1);
			Intent intent = new Intent(TenderAffirmActivity.this,
					MyRegularDebtActivity.class);
			startActivity(intent);
		}
		finish();
	}

	// 快快享福投标查看记录
	public void toEnjoyviewRecord() {
		if ("501".equals(bidType)) {
			SystemUtils.onEvent("Expericence_Result_CheckRecord", 1);
			Intent intent = new Intent(TenderAffirmActivity.this,
					MyExperienceGoldActivity.class);
			startActivity(intent);
		} else {
			SystemUtils.onEvent("Regular_Result_CheckRecord", 1);
			Intent intent = new Intent(TenderAffirmActivity.this,
					MyRegularDebtActivity.class);
			startActivity(intent);
		}
		finish();
	}
}
